/* uDig - User Friendly Desktop Internet GIS client
 * http://udig.refractions.net
 * (C) 2004-2008, Refractions Research Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation;
 * version 2.1 of the License.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 */
package symbology;

import java.util.ArrayList;
import feature.Feature;

/**
 * A ScaleSymbolizer selects appropriate symbols based on the map scale
 * <p>
 * Like the RangeSymbolizer, it contains a sequence of ranges 
 * </p>
 * @author John
 * @since 1.1.0
 */
public class ScaleSymbolizer implements Symbolizer {
    
    ArrayList<Range> ranges;
    
    public ScaleSymbolizer() {
        ranges = new ArrayList<Range>();
    }
    
    public void add(Range range) {
        ranges.add( range ); 
    }

    /**
     * addSymbols selects one of the ranges based on map scale, and gets symbols from the
     * corresponding Symbolizer.
     */
    public void addSymbols( Feature feature, double scale, Symbols symbols ) {
        for (Range r: ranges)
            if (scale >= r.min && scale <= r.max) {
                r.symbolizer.addSymbols(feature, scale, symbols);
                break;
            }
    }

}
